<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../includes/common.jsp" %>

<jsp:include page="mark.view-toolbar.jsp"></jsp:include>

<fieldset>
    <legend>Sinh viên</legend>
    <p>Họ tên: <b>${mark.studentSurname} ${mark.studentName}</b></p>
    <c:if test="${not empty mark.studentId}">
	    <p>Mã số SV: <b>${mark.studentId}</b></p>
    </c:if>
    <c:if test="${not empty mark.studentBirthday}">
	    <p>Ngày sinh: <b>${u:formatDate(mark.studentBirthday)}</b></p>
    </c:if>
</fieldset>

<fieldset>
    <legend>Bài làm</legend>
	<p>Mã đề: <b><a href="${scriptPath}?action=testversion.view&verid=${mark.testVersion.id}">
	       ${empty mark.testVersion.code ? '&lt;không tên&gt;' : mark.testVersion.code}</a></b></p>
	<p>Điểm: <b>${u:round(mark.mark*100)}%</b></p>
</fieldset>

<c:set var="type" value="${test.type=='radio' ? 'radio' : 'checkbox'}"></c:set>
<c:set var="i" value="1"></c:set>

<c:forEach items="${test.sections}" var="section">
<div>
    <c:set var="questionIds" value="${mark.testVersion.data.questionsOrder[section.id]}"></c:set>
    <c:forEach items="${questionIds}" var="questionId">
        <c:set var="question" value="${section.questionById[questionId]}"></c:set>
		<div>
			
			<div class="question-number-wrapper">
			     <b><a href="?action=question.view&qv_id=${question.id}">Câu ${i}</a></b> (${question.mark} điểm)
			</div>
			${question.content}

            <div class="answer-list-wrapper">
            <c:set var="answerIds" value="${mark.testVersion.data.answersOrder[section.id][questionId]}"></c:set>
            <c:set var="j" value="0"></c:set>
            <c:forEach items="${answerIds}" var="answerId">
                <c:set var="answer" value="${question.answerById[answerId]}"></c:set>

			   <c:set var="choosed" scope="page" value="${false}"></c:set>
			   <c:forEach items="${mark.choices[question.id]}" var="choice">
			         <c:if test="${choice == answer.id}">
						   <c:set var="choosed" scope="page" value="${true}"></c:set>
			         </c:if>
			   </c:forEach>
			
               <div class="answer-wrapper">
                    <div class="check-wrapper">
			     		<input type="${type}" name="q${question.id}"
			     		      ${choosed ? 'checked="checked"' : ''} disabled="disabled"></input>
					</div>
                    <c:if test="${choosed}">
                        <div class="marker-wrapper">
                        <c:choose>
                            <c:when test="${answer.correct}">
                                <img src="${templatePath}/images/right.png" alt="right answer" width="16px" height="16px" />
                            </c:when>
                            <c:when test="${!answer.correct}">
                                <img src="${templatePath}/images/wrong.png" alt="wrong answer" width="16px" height="16px" />
                            </c:when>
                        </c:choose>
                        </div>
                    </c:if>
                    <div class="answer-number-wrapper">
                       <b>${u:alpha(j)}</b>.
                    </div>
                    <div ${answer.correct ? 'style="color:red"' : ''}>
    					${answer.content}
    				</div>
			   </div>
                <c:set var="j" value="${j+1}"></c:set>  
			</c:forEach>
			</div>
		</div>
		<c:set var="i" value="${i+1}"></c:set>
	</c:forEach>
</div>
</c:forEach>

<jsp:include page="mark.view-toolbar.jsp"></jsp:include>